home *** CD-ROM | disk | FTP | other *** search
- Path: druid.borland.com!usenet
- From: pete@borland.com (Pete Becker)
- Newsgroups: comp.lang.c++
- Subject: Re: STL: Finding an object in a set of Pointers
- Date: 15 Apr 1996 19:16:03 GMT
- Organization: Borland International
- Message-ID: <4ku79j$g1m@druid.borland.com>
- References: <4klmjm$kul@access4.digex.net>
- NNTP-Posting-Host: pbecker.borland.com
- Mime-Version: 1.0
- Content-Type: Text/Plain; charset=ISO-8859-1
- X-Newsreader: WinVN 0.99.5
-
- In article <4klmjm$kul@access4.digex.net>, car@access4.digex.net says...
- >
- >
- >I am using an STL set to contain *pointers* to objects.
- >
- >Problem: I want to find out if an object I just created is
- >logically contained in the set.
- >
- >The find() function will tell me whether the same *address*
- >is already in the set, but I need to follow the pointers and
- >invoke operator==() on the objects.
- >
- >Is there an elegant way I can do this without writing my
- >own loop, de-referencing, and comparing?
-
- Use find_if, and provide a predicate that handles the dereferencing.
- -- Pete
-
-